<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/include.inc.jsp"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]> <html lang="en" class="no-js"> <!--<![endif]-->
<!-- BEGIN HEAD -->
<head>
<base href="<%=basePath%>">
<meta charset="utf-8" />
<title>管理员登录</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta content="width=device-width, initial-scale=1.0" name="viewport" />
<meta content="" name="description" />
<meta content="" name="author" />
<meta name="MobileOptimized" content="320">
<!-- BEGIN GLOBAL MANDATORY STYLES -->
<link href="assets/plugins/font-awesome/css/font-awesome.min.css"
	rel="stylesheet" type="text/css" />
<link href="assets/plugins/bootstrap/css/bootstrap.min.css"
	rel="stylesheet" type="text/css" />
<link href="assets/plugins/uniform/css/uniform.default.css"
	rel="stylesheet" type="text/css" />
<!-- END GLOBAL MANDATORY STYLES -->
<!-- BEGIN PAGE LEVEL STYLES -->
<link rel="stylesheet" type="text/css"
	href="assets/plugins/select2/select2_metro.css" />
<!-- END PAGE LEVEL SCRIPTS -->
<!-- BEGIN THEME STYLES -->
<link href="assets/css/style-metronic.css" rel="stylesheet"
	type="text/css" />
<link href="assets/css/style.css" rel="stylesheet" type="text/css" />
<link href="assets/css/style-responsive.css" rel="stylesheet"
	type="text/css" />
<link href="assets/css/plugins.css" rel="stylesheet" type="text/css" />
<link href="assets/css/themes/default.css" rel="stylesheet"
	type="text/css" id="style_color" />
<link href="assets/css/pages/login-soft.css" rel="stylesheet"
	type="text/css" />
<link href="assets/css/custom.css" rel="stylesheet" type="text/css" />
<!-- END THEME STYLES -->
<link rel="shortcut icon" href="favicon.ico" />
</head>
<!-- END HEAD -->
<!-- BEGIN BODY -->
<body class="login">
	<!-- BEGIN LOGO -->
	<div class="logo">
		<h4 style="color: #4d90fe;">华瑞采购平台管理系统</h4>
	</div>
	<!-- END LOGO -->
	<!-- BEGIN LOGIN -->
	<div class="content">
		<!-- BEGIN LOGIN FORM -->
		<form class="login-form" id="loginForm" method="post">
			<h4 class="form-title" style="text-align: center;">用户登录</h4>
			<div class="form-group">
				<!--ie8, ie9 does not support html5 placeholder, so we just show field title for that-->
				<label class="control-label visible-ie8 visible-ie9">用户名 </label>
				<div class="input-icon">
					<i class="fa fa-user"></i> <input
						class="form-control placeholder-no-fix" type="text"
						autocomplete="off" placeholder="用户名" id="uaccount" name="username" />
				</div>
				<c:if test="${userName != null}">
					<span for="uaccount" class="help-block">${userName}</span>
				</c:if>
			</div>
			<div class="form-group">
				<label class="control-label visible-ie8 visible-ie9">密码</label>
				<div class="input-icon">
					<i class="fa fa-lock"></i> <input
						class="form-control placeholder-no-fix" type="password"
						id="upassword" autocomplete="off" placeholder="密码" name="password" />
				</div>
				<c:if test="${password != null}">
					<span for="upassword" class="help-block">${password}</span>
				</c:if>
			</div>
			<div class="form-group">
				<!--ie8, ie9 does not support html5 placeholder, so we just show field title for that-->
				<div class="col-md-5" style="padding-left: 0;">
					<label class="control-label visible-ie8 visible-ie9">验证码 </label>
					<div class="input-icon">
						<i class="fa fa-info-circle"></i> <input
							class="form-control placeholder-no-fix input-small" type="text"
							autocomplete="off" placeholder="验证码" id="vCode" name="vCode" />
					</div>
				</div>
				<div class="col-md-4 input-small" style="margin-left: 10px;vertical-align: middle;">
					<img id="imgObj" alt="图形验证码" onclick="changeImg()" src="code.htm">
				</div>
				<div class="col-md-3 input-small" style="text-align: center;vertical-align: middle;">
					<a href="javascript:void(0);" onclick="changeImg()">换一张</a>
				</div>
			</div>
			<div class="form-actions"
				style="padding-bottom: 0;text-align: center;padding-top: 15px;">
				<div id="loginAlert" class="alert alert-danger"
					style="padding: 3px 15px;margin-bottom: 5px;border: 1px dashed red; display: none;">
					<button class="close" data-close="alert"></button>
					<span id="show_error" style="color:red;"></span>
				</div>
				
				<button type="button" id="login_submit_btn"
					class="btn blue pull-center">
					登录 <i class="m-icon-swapright m-icon-white"></i>
				</button>
			</div>
		</form>
		<!-- END LOGIN FORM -->

	</div>
	<!-- END LOGIN -->
	<!-- BEGIN COPYRIGHT -->
	<div class="copyright">2016版权所有: ----华瑞有限公司</div>
	<!-- END COPYRIGHT -->
	<!-- BEGIN JAVASCRIPTS(Load javascripts at bottom, this will reduce page load time) -->
	<!-- BEGIN CORE PLUGINS -->
	<!--[if lt IE 9]>
	<script src="assets/plugins/respond.min.js"></script>
	<script src="assets/plugins/excanvas.min.js"></script> 
	<![endif]-->
	<script src="assets/plugins/jquery-1.10.2.min.js" type="text/javascript"></script>
	<script src="assets/plugins/jquery-migrate-1.2.1.min.js" type="text/javascript"></script>
	<script src="assets/plugins/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
	<script src="assets/plugins/bootstrap-hover-dropdown/twitter-bootstrap-hover-dropdown.min.js" type="text/javascript"></script>
	<script src="assets/plugins/jquery-slimscroll/jquery.slimscroll.min.js"	type="text/javascript"></script>
	<script src="assets/plugins/jquery.blockui.min.js" type="text/javascript"></script>
	<script src="assets/plugins/jquery.cookie.min.js" type="text/javascript"></script>
	<script src="assets/plugins/uniform/jquery.uniform.min.js" type="text/javascript"></script>
	<!-- END CORE PLUGINS -->
	
	<!-- BEGIN PAGE LEVEL PLUGINS -->
	<script	src="assets/plugins/jquery-validation/dist/jquery.validate.min.js" type="text/javascript"></script>
	<script src="assets/plugins/backstretch/jquery.backstretch.min.js" type="text/javascript"></script>
	<script src="assets/scripts/app.js" type="text/javascript"></script>
	<!-- END PAGE LEVEL SCRIPTS -->
	
	<script src="js/page/login.js" type="text/javascript"></script>
	<script type="text/javascript">
		function changeImg() {
        	var imgSrc = $("#imgObj");
        	var src = imgSrc.attr("src");
        	imgSrc.attr("src", chgUrl(src));
    	}
    	//时间戳   
    	//为了使每次生成图片不一致，即不让浏览器读缓存，所以需要加上时间戳   
    	function chgUrl(url) {
        	var timestamp = (new Date()).valueOf();
	        url = url.substring(0, 17);
	        if ((url.indexOf("&") >= 0)) {
	            url = url + "×tamp=" + timestamp;
	        } else {
	            url = url + "?timestamp=" + timestamp;
	        }
        	return url;
    	}
    	function ajaxToLogin(){
    		var params=loginForm.serialize();
    		var errorAlert=$("#loginAlert");
    		var show_error =$("#show_error");
    	    if(params!=null&&params!=''){
    	    	errorAlert.hide();
    	    	$.ajax({
    	    		url:'web/doLogin.htm',
    	    		data:params,
    	    		type:'post',
    	    		success:function(data){
    	    			if(data==1){
    	    				//这里执行跳到主页
    	    				window.location.href="web/index.htm";
    	    			}else{//根据返回内容提示错误
    	    				var msg;
    	    				switch(data){
    	    				case -1:
    	    					msg="账号密码错误";
    	    					break
    	    				case -2:
    	    					msg="密码错误";
    	    					break;
    	    				case -3:
    	    					msg="验证码错误";
    	    					break;
    	    				}
    	    				show_error.html(msg);
    	    				changeImg();
    	    				errorAlert.show();
    	    			}
    	    		},
    	    		error: function(XMLHttpRequest, textStatus, errorThrown) {
    	    			 /* alert(XMLHttpRequest.status);
    	    			 alert(XMLHttpRequest.readyState);
    	    			 alert(textStatus); */
    	    			 var msg = XMLHttpRequest.status + "出现错误，错误码 "+textStatus
    	    			 show_error.html(msg);
    	    		}
    	    	});
    	    }
    	}
		jQuery(document).ready(function() {
			App.init();
			Login.init();
			$("#login_submit_btn").click(function(){
				$("#loginForm").submit();
			});
		});
	</script>
	<!-- END JAVASCRIPTS -->
</body>
<!-- END BODY -->
</html>